package com.niit.controller;

import com.niit.entity.Student;
import com.niit.mapper.StudentMapper;
import com.niit.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TestGetAllStudents {
    public static void main(String[] args) {
        // 获取 SqlSession 对象
        SqlSession sqlSession = MybatisUtil.getSqlSession();

        // 获取 Mapper对象
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);

        // 第1此查询
        List<Student> students = studentMapper.getAllStudents();
        students.forEach(student -> System.out.println(student.getSbatch()));

        // 第2次查询
        List<Student> students2 = studentMapper.getAllStudents();
        students2.forEach(student -> System.out.println(student.getSbatch()));

    }
}
